
#ifndef _MEMBER_BLAYOUT_H_
#define _MEMBER_BLAYOUT_H_

#include <BSpring>
#include <BLayout>
#include <BSpacer>
#include <BWidget>

#define layout_member(layout)		((member_BLayout*)((BLayout*)layout)->_ptr)

namespace BWE
{
	class LayoutItem
	{
	public:
		LayoutItem();
		LayoutItem(const LayoutItem& other);
		~LayoutItem();

		void clear();
		bool empty() const;
		bool ignored() const;

		void attach(BWidget* host);
		void detach(BWidget* host);

		bool prepare(int remain);
		BSize size() const;
		BSize minSize() const;
		BSize maxSize() const;
		BSize sizeHint() const;
		BSize fixedSize() const;
		BSizeStretch sizeStretch() const;
		BSizePolicy sizePolicy() const;

		void adjust(int x, int y, int w, int h);

		void operator = (BWidget* widget);
		void operator = (BLayout* layout);
		void operator = (BSpacer* spacer);
		void operator = (BSpring* spring);

		bool operator == (const BObject* object) const;
		bool operator == (const BWidget* widget) const;
		bool operator == (const BLayout* layout) const;
		bool operator == (const BSpacer* spacer) const;
		bool operator == (const BSpring* spring) const;

		bool operator != (const BObject* object) const;
		bool operator != (const BWidget* widget) const;
		bool operator != (const BLayout* layout) const;
		bool operator != (const BSpacer* spacer) const;
		bool operator != (const BSpring* spring) const;

		BWidgetHolder	widget;
		BLayoutHolder	layout;
		BSpacerHolder	spacer;
		BSpringHolder	spring;

		BRect			rect;
		Align			align;
		BSize			realSize;
		bool			finishWidth;
		bool			finishHeight;
	};

	class member_BLayout
	{
	public:
		member_BLayout(BLayout* layout);
		~member_BLayout();

		BLayout*		boss;
		BWidget*		host;
		BLayout*		parent;

		bool			dirty;
		BSizeStretch	sizeStretch;
		BSizePolicy		sizePolicy;
		BSize			fixedSize;
		BSize			minSize;
		BSize			maxSize;
		BRect			rect;
		int				border;
		int				spacing;

	};
}

#endif
